@extends('public')
@section('css')
    <style>
        .input_1{border:solid #cfcfcf 1px;width:74px;height:38px;font-size:16px; border-radius:4px; text-align:center;margin-right:14px;font-family:Microsoft Yahei;color:#CCC;}
        .input_2{ border:1px solid #cfcfcf; width:256px; height:80px; line-height:20px; outline-width:0;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px;font-family:Microsoft Yahei; color:#333333; font-size:16px; text-indent:10px}
    </style>
@endsection
@section('content')
    <div class="wrap">
        <div class="main_user">
            <div class="main_L" >

                <div class="side_box">
                    <div class="user_pic"><img src="{{asset('images/user_pic.jpg')}}" width="80" height="80" /></div>
                    <div class="user_name">您好！{{$user->name}}</div>
                    <div class="side_nav">
                        <ul>
                            <li>
                                <a href="{{url('user/myinformation')}}"><span>个人资料</span></a>
                            </li>
                            <li>
                                <a href="#"><span>我的订单</span></a>
                            </li>
                            <li>
                                <a href="{{url('user/address')}}"><span>地址管理</span></a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="main_R">

                <div class="pro_form">
                    <form action="{{url('user/update/'.$address->id)}}" method="POST">
                        {{ csrf_field() }}
                        <dl>
                            <dt>所在地区：</dt>
                            <dd><select name="provinceCode" id="provinceBtn" class="input_1">
                                    <option value="" selected="selected">--请选择-</option>
                                    @foreach($province as $k=>$v)
                                    <option  @if($v->code == $address->provinceCode)  selected="selected"  @endif  value="{{$v->code}}">{{$v->name}}</option>
                                    @endforeach
                                </select>
                                <select name="cityCode" id="cityBtn" class="input_1">
                                    <option value="" selected="selected">--请选择--</option>
                                    @foreach($city as $k=>$v)
                                        <option  @if($v->code == $address->cityCode)  selected="selected"  @endif  value="{{$v->code}}">{{$v->name}}</option>
                                    @endforeach
                                </select>
                                <select name="areaCode" id="areaBtn" class="input_1">
                                    <option value="" selected="selected">--请选择--</option>
                                    @foreach($area as $k=>$v)
                                        <option  @if($v->code == $address->areaCode)  selected="selected"  @endif  value="{{$v->code}}">{{$v->name}}</option>
                                    @endforeach
                                </select>

                            </dd>
                        </dl>
                        <dl>
                            <dt>详细地址：</dt>
                            <dd>
                                <textarea rows="3" name="address" cols="20" class="input_2">{{$address->address}}</textarea>
                            </dd>
                        </dl>
                        <dl>
                            <dt>邮政编码：</dt>
                            <dd><input class="input" name="zipcode" type="text" value="{{$address->zipcode}}" /></dd>
                        </dl>
                        <dl>
                            <dt>收货人：</dt>
                            <dd><input class="input" name="userName" type="text" value="{{$address->userName}}" /></dd>
                        </dl>
                        <dl>
                            <dt>手机号码：</dt>
                            <dd><input class="input" name="phone" type="text" value="{{$address->phone}}" /></dd>
                        </dl>
                        <dl>
                            <dt>&nbsp;</dt>
                            <dd>
                                <input class="btn" name="" type="submit" value="保存" />
                            </dd>
                        </dl>
                        <div class=" clear"></div>
                    </form>
                </div>

            </div>

            <div class="clear"></div>
        </div>
    </div>

@stop
@section('js')
    <script>
        $('#provinceBtn').change(function(){
            var code = $(this).val();
            if(code)
            {
                $.ajax({
                    type: 'GET',
                    url: "{{url('user/getcity')}}/"+code,
                    dataType: 'json',
                }).always(function(data){
                    var html = '<option value="" selected="selected">--请选择--</option>';
                    $(data).each(function(k,v){
                        html += '<option value="'+v.code+'">'+v.name+'</option>';
                    });
                    $('#cityBtn').html(html);
                })
            }else
                $('#cityBtn').html('<option value="">请选择</option>');
            });

        $('#cityBtn').change(function(){
            var code = $(this).val();
            if(code)
            {
                $.ajax({
                    type: 'GET',
                    url: "{{url('user/getarea')}}/"+code,
                    dataType: 'json',
                }).always(function(data){
                    var html = '<option value="" selected="selected">--请选择--</option>';
                    $(data).each(function(k,v){
                        html += '<option value="'+v.code+'">'+v.name+'</option>';
                    });
                    $('#areaBtn').html(html);
                })
            }else
                $('#areaBtn').html('<option value="">请选择</option>');
        });
    </script>
@endsection